import org.junit.Test;

import static org.junit.Assert.*;

public class NGuessNumberTest {

    @org.junit.Test
    public void generateAnswerTest() {
        NGuessNumber nGuessNumber = new NGuessNumber();
        String answer = nGuessNumber.generateAnswer();
        assert answer.length() == 4 : "数组长度不为4";
        for (int j = 1; j < answer.toCharArray().length; j++) {
            for (int i = 0; i < j; i++) {
                assert answer.toCharArray()[j] == answer.toCharArray()[i] : "重复";
            }
        }
    }

    @org.junit.Test
    public void getPlayerInputTest() {
        NGuessNumber nGuessNumber = new NGuessNumber();
        String input = nGuessNumber.getPlayerInput();
        assert input.length() == 4 : "数组长度不为4";
    }

    @Test
    public void compareGuessAnswerTest() {
        String input = "1234";
        String answer = "1234";
        NGuessNumber nGuessNumber = new NGuessNumber();
        assert nGuessNumber.compareGuessAnswer(answer,input).equals("4A4B") : "4A4B";
    }

    @Test
    public void isWinTest() {
        NGuessNumber nGuessNumber = new NGuessNumber();
        assert nGuessNumber.isWin("4A4B") : "正确";
    }
}